home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / perl5 / Glib / Object.pod < prev    next >
Encoding:
Text File  |  2008-11-04  |  11.8 KB  |  700 lines

  1. =head1 NAME
  2.  
  3. Glib::Object -  Bindings for GObject
  4.  
  5. =for position DESCRIPTION
  6.  
  7. =head1 DESCRIPTION
  8.  
  9. GObject is the base object class provided by the gobject library.  It provides
  10. object properties with a notification system, and emittable signals.
  11.  
  12. Glib::Object is the corresponding Perl object class.  Glib::Objects are
  13. represented by blessed hash references, with a magical connection to the
  14. underlying C object.
  15.  
  16. =cut
  17.  
  18.  
  19.  
  20. =head1 HIERARCHY
  21.  
  22.   Glib::Object
  23.  
  24. =for object Glib::Object Bindings for GObject
  25. =cut
  26.  
  27.  
  28.  
  29.  
  30. =head1 METHODS
  31.  
  32. =head2 object = $class->B<new> (...)
  33.  
  34. =over
  35.  
  36. =over
  37.  
  38. =item * ... (list) key/value pairs, property values to set on creation
  39.  
  40. =back
  41.  
  42.  
  43.  
  44.  
  45. Instantiate a Glib::Object of type I<$class>.  Any key/value pairs in
  46. I<...> are used to set properties on the new object; see C<set>.
  47. This is designed to be inherited by Perl-derived subclasses (see
  48. L<Glib::Object::Subclass>), but you can actually use it to create
  49. any GObject-derived type.
  50.  
  51.  
  52. =back
  53.  
  54. =head2 scalar = Glib::Object-E<gt>B<new_from_pointer> ($pointer, $noinc=FALSE)
  55.  
  56. =over
  57.  
  58. =over
  59.  
  60. =item * $pointer (unsigned) a C pointer value as an integer.
  61.  
  62. =item * $noinc (boolean) if true, do not increase the GObject's reference count when creating the Perl wrapper.  this typically means that when the Perl wrapper will own the object.  in general you don't want to do that, so the default is false.
  63.  
  64. =back
  65.  
  66.  
  67.  
  68.  
  69. Create a Perl Glib::Object reference for the C object pointed to by I<$pointer>.
  70. You should need this I<very> rarely; it's intended to support foreign objects.
  71.  
  72. NOTE: the cast from arbitrary integer to GObject may result in a core dump without
  73. warning, because the type-checking macro G_OBJECT() attempts to dereference the
  74. pointer to find a GTypeClass structure, and there is no portable way to validate
  75. the pointer.
  76.  
  77.  
  78. =back
  79.  
  80. =head2 unsigned = $object-E<gt>B<get_data> ($key)
  81.  
  82. =over
  83.  
  84. =over
  85.  
  86. =item * $key (string) 
  87.  
  88. =back
  89.  
  90.  
  91. Fetch the integer stored under the object data key I<$key>.  These values do not
  92. have types; type conversions must be done manually.  See C<set_data>.
  93.  
  94.  
  95. =back
  96.  
  97. =head2 $object-E<gt>B<set_data> ($key, $data)
  98.  
  99. =over
  100.  
  101. =over
  102.  
  103. =item * $key (string) 
  104.  
  105. =item * $data (scalar) 
  106.  
  107. =back
  108.  
  109.  
  110. GObject provides an arbitrary data mechanism that assigns unsigned integers
  111. to key names.  Functionality overlaps with the hash used as the Perl object
  112. instance, so we strongly recommend you use hash keys for your data storage.
  113. The GObject data values cannot store type information, so they are not safe
  114. to use for anything but integer values, and you really should use this method
  115. only if you know what you are doing.
  116.  
  117.  
  118. =back
  119.  
  120. =head2 pspec = $object_or_class_name->B<find_property> ($name)
  121.  
  122. =over
  123.  
  124. =over
  125.  
  126. =item * $name (string) 
  127.  
  128. =back
  129.  
  130. Find the definition of object property I<$name> for I<$object_or_class_name>; for
  131. the returned data see L<Glib::Object::list_properties>.
  132.  
  133. =back
  134.  
  135. =head2 $object-E<gt>B<freeze_notify> 
  136.  
  137. =over
  138.  
  139.  
  140. Stops emission of "notify" signals on I<$object>. The signals are queued
  141. until C<thaw_notify> is called on I<$object>.
  142.  
  143.  
  144. =back
  145.  
  146. =head2 list = $object-E<gt>B<get> (...)
  147.  
  148. =over
  149.  
  150. =over
  151.  
  152. =item * ... (list) list of property names
  153.  
  154. =back
  155.  
  156.  
  157. Fetch and return the values for the object properties named in I<...>.
  158.  
  159.  
  160. =back
  161.  
  162. =head2 $object->B<set> (key => $value, ...)
  163.  
  164. =over
  165.  
  166. =over
  167.  
  168. =item * ... (list) key/value pairs
  169.  
  170. =back
  171.  
  172.  
  173. Set object properties.
  174.  
  175.  
  176. =back
  177.  
  178. =head2 list = $object_or_class_name->B<list_properties>
  179.  
  180. =over
  181.  
  182. =over
  183.  
  184. =back
  185.  
  186. List all the object properties for I<$object_or_class_name>; returns them as
  187. a list of hashes, containing these keys:
  188.  
  189. =over
  190.  
  191. =item name
  192.  
  193. The name of the property
  194.  
  195. =item type
  196.  
  197. The type of the property
  198.  
  199. =item owner_type
  200.  
  201. The type that owns the property
  202.  
  203. =item descr
  204.  
  205. The description of the property
  206.  
  207. =item flags
  208.  
  209. The Glib::ParamFlags of the property
  210.  
  211. =back
  212.  
  213.  
  214. =back
  215.  
  216. =head2 $object-E<gt>B<notify> ($property_name)
  217.  
  218. =over
  219.  
  220. =over
  221.  
  222. =item * $property_name (string) 
  223.  
  224. =back
  225.  
  226.  
  227. Emits a "notify" signal for the property I<$property> on I<$object>.
  228.  
  229.  
  230. =back
  231.  
  232. =head2 gpointer = $object-E<gt>B<get_pointer> 
  233.  
  234. =over
  235.  
  236.  
  237. Complement of C<new_from_pointer>.
  238.  
  239.  
  240. =back
  241.  
  242. =head2 list = $object-E<gt>B<get_property> (...)
  243.  
  244. =over
  245.  
  246. =over
  247.  
  248. =back
  249.  
  250.  
  251. Alias for C<get>.
  252.  
  253.  
  254. =back
  255.  
  256. =head2 $object->B<set_property> (key => $value, ...)
  257.  
  258. =over
  259.  
  260. =over
  261.  
  262. =back
  263.  
  264.  
  265. Alias for C<set>.
  266.  
  267.  
  268. =back
  269.  
  270. =head2 unsigned = $object_or_class_name-E<gt>B<signal_add_emission_hook> ($detailed_signal, $hook_func, $hook_data=undef)
  271.  
  272. =over
  273.  
  274. =over
  275.  
  276. =item * $detailed_signal (string) of the form "signal-name::detail"
  277.  
  278. =item * $hook_func (subroutine) 
  279.  
  280. =item * $hook_data (scalar) 
  281.  
  282. =back
  283.  
  284. Add an emission hook for a signal.  The hook will be called for any emission
  285. of that signal, independent of the instance.  This is possible only for
  286. signals which don't have the C<G_SIGNAL_NO_HOOKS> flag set.
  287.  
  288. The I<$hook_func> should be reference to a subroutine that looks something
  289. like this:
  290.  
  291.   sub emission_hook {
  292.       my ($invocation_hint, $parameters, $hook_data) = @_;
  293.       # $parameters is a reference to the @_ to be passed to
  294.       # signal handlers, including the instance as $parameters->[0].
  295.       return $stay_connected;  # boolean
  296.   }
  297.  
  298. This function returns an id that can be used with C<remove_emission_hook>.
  299.  
  300. Since 1.100.
  301.  
  302. =back
  303.  
  304. =head2 list = $instance-E<gt>B<signal_chain_from_overridden> (...)
  305.  
  306. =over
  307.  
  308. =over
  309.  
  310. =item * ... (list) 
  311.  
  312. =back
  313.  
  314.  
  315. Chain up to an overridden class closure; it is only valid to call this from
  316. a class closure override.
  317.  
  318. Translation: because of various details in how GObjects are implemented,
  319. the way to override a virtual method on a GObject is to provide a new "class
  320. closure", or default handler for a signal.  This happens when a class is
  321. registered with the type system (see Glib::Type::register and
  322. L<Glib::Object::Subclass>).  When called from inside such an override, this
  323. method runs the overridden class closure.  This is equivalent to calling
  324. $self->SUPER::$method (@_) in normal Perl objects.
  325.  
  326.  
  327. =back
  328.  
  329. =head2 unsigned = $instance-E<gt>B<signal_connect> ($detailed_signal, $callback, $data=undef)
  330.  
  331. =over
  332.  
  333. =over
  334.  
  335. =item * $detailed_signal (string) 
  336.  
  337. =item * $callback (subroutine) 
  338.  
  339. =item * $data (scalar) arbitrary data to be passed to each invocation of I<callback>
  340.  
  341. =back
  342.  
  343.  
  344.  
  345.  
  346. Register I<callback> to be called on each emission of I<$detailed_signal>.
  347. Returns an identifier that may be used to remove this handler with
  348. C<< $object->signal_handler_disconnect >>.
  349.  
  350.  
  351. =back
  352.  
  353. =head2 unsigned = $instance-E<gt>B<signal_connect_after> ($detailed_signal, $callback, $data=undef)
  354.  
  355. =over
  356.  
  357. =over
  358.  
  359. =item * $detailed_signal (string) 
  360.  
  361. =item * $callback (scalar) 
  362.  
  363. =item * $data (scalar) 
  364.  
  365. =back
  366.  
  367.  
  368. Like C<signal_connect>, except that I<$callback> will be run after the default
  369. handler.
  370.  
  371.  
  372. =back
  373.  
  374. =head2 unsigned = $instance-E<gt>B<signal_connect_swapped> ($detailed_signal, $callback, $data=undef)
  375.  
  376. =over
  377.  
  378. =over
  379.  
  380. =item * $detailed_signal (string) 
  381.  
  382. =item * $callback (scalar) 
  383.  
  384. =item * $data (scalar) 
  385.  
  386. =back
  387.  
  388.  
  389. Like C<signal_connect>, except that I<$data> and I<$object> will be swapped
  390. on invocation of I<$callback>.
  391.  
  392.  
  393. =back
  394.  
  395. =head2 retval = $object->B<signal_emit> ($name, ...)
  396.  
  397. =over
  398.  
  399. =over
  400.  
  401. =item * $name (string) the name of the signal
  402.  
  403. =item * ... (list) any arguments to pass to handlers.
  404.  
  405. =back
  406.  
  407.  
  408.  
  409.  
  410.  
  411. Emit the signal I<name> on I<$object>.  The number and types of additional
  412. arguments in I<...> are determined by the signal; similarly, the presence
  413. and type of return value depends on the signal being emitted.
  414.  
  415.  
  416. =back
  417.  
  418. =head2 $ihint = $instance->B<signal_get_invocation_hint>
  419.  
  420. =over
  421.  
  422. Get a reference to a hash describing the innermost signal currently active
  423. on C<$instance>.  Returns undef if no signal emission is active.  This
  424. invocation hint is the same object passed to signal emission hooks, and
  425. contains these keys:
  426.  
  427. =over
  428.  
  429. =item signal_name
  430.  
  431. The name of the signal being emitted.
  432.  
  433. =item detail
  434.  
  435. The detail passed on for this emission.  For example, a C<notify> signal will
  436. have the property name as the detail.
  437.  
  438. =item run_type
  439.  
  440. The current stage of signal emission, one of "run-first", "run-last", or
  441. "run-cleanup".
  442.  
  443. =back
  444.  
  445.  
  446. =back
  447.  
  448. =head2 $object-E<gt>B<signal_handler_block> ($handler_id)
  449.  
  450. =over
  451.  
  452. =over
  453.  
  454. =item * $handler_id (unsigned) 
  455.  
  456. =back
  457.  
  458. =back
  459.  
  460. =head2 $object-E<gt>B<signal_handler_disconnect> ($handler_id)
  461.  
  462. =over
  463.  
  464. =over
  465.  
  466. =item * $handler_id (unsigned) 
  467.  
  468. =back
  469.  
  470. =back
  471.  
  472. =head2 boolean = $object-E<gt>B<signal_handler_is_connected> ($handler_id)
  473.  
  474. =over
  475.  
  476. =over
  477.  
  478. =item * $handler_id (unsigned) 
  479.  
  480. =back
  481.  
  482. =back
  483.  
  484. =head2 $object-E<gt>B<signal_handler_unblock> ($handler_id)
  485.  
  486. =over
  487.  
  488. =over
  489.  
  490. =item * $handler_id (unsigned) 
  491.  
  492. =back
  493.  
  494. =back
  495.  
  496. =head2 integer = $instance-E<gt>B<signal_handlers_block_by_func> ($func, $data=undef)
  497.  
  498. =over
  499.  
  500. =over
  501.  
  502. =item * $func (subroutine) function to block
  503.  
  504. =item * $data (scalar) data to match, ignored if undef
  505.  
  506. =back
  507.  
  508.  
  509.  
  510. =back
  511.  
  512. =head2 integer = $instance-E<gt>B<signal_handlers_disconnect_by_func> ($func, $data=undef)
  513.  
  514. =over
  515.  
  516. =over
  517.  
  518. =item * $func (subroutine) function to block
  519.  
  520. =item * $data (scalar) data to match, ignored if undef
  521.  
  522. =back
  523.  
  524.  
  525.  
  526. =back
  527.  
  528. =head2 integer = $instance-E<gt>B<signal_handlers_unblock_by_func> ($func, $data=undef)
  529.  
  530. =over
  531.  
  532. =over
  533.  
  534. =item * $func (subroutine) function to block
  535.  
  536. =item * $data (scalar) data to match, ignored if undef
  537.  
  538. =back
  539.  
  540.  
  541.  
  542. =back
  543.  
  544. =head2 scalar = $object_or_class_name-E<gt>B<signal_query> ($name)
  545.  
  546. =over
  547.  
  548. =over
  549.  
  550. =item * $name (string) 
  551.  
  552. =back
  553.  
  554. Look up information about the signal I<$name> on the instance type
  555. I<$object_or_class_name>, which may be either a Glib::Object or a package
  556. name.
  557.  
  558. See also C<Glib::Type::list_signals>, which returns the same kind of
  559. hash refs as this does.
  560.  
  561. Since 1.080.
  562.  
  563. =back
  564.  
  565. =head2 $object_or_class_name-E<gt>B<signal_remove_emission_hook> ($signal_name, $hook_id)
  566.  
  567. =over
  568.  
  569. =over
  570.  
  571. =item * $signal_name (string) 
  572.  
  573. =item * $hook_id (unsigned) 
  574.  
  575. =back
  576.  
  577. Remove a hook that was installed by C<add_emission_hook>.
  578.  
  579. Since 1.100.
  580.  
  581. =back
  582.  
  583. =head2 $instance-E<gt>B<signal_stop_emission_by_name> ($detailed_signal)
  584.  
  585. =over
  586.  
  587. =over
  588.  
  589. =item * $detailed_signal (string) 
  590.  
  591. =back
  592.  
  593. =back
  594.  
  595. =head2 $object-E<gt>B<thaw_notify> 
  596.  
  597. =over
  598.  
  599.  
  600. Reverts the effect of a previous call to C<freeze_notify>. This causes all
  601. queued "notify" signals on I<$object> to be emitted.
  602.  
  603.  
  604. =back
  605.  
  606. =head2 boolean = Glib::Object-E<gt>B<set_threadsafe> ($threadsafe)
  607.  
  608. =over
  609.  
  610. =over
  611.  
  612. =item * $threadsafe (boolean) 
  613.  
  614. =back
  615.  
  616. Enables/disables threadsafe gobject tracking. Returns whether or not tracking
  617. will be successful and thus whether using perl ithreads will be possible.
  618.  
  619. =back
  620.  
  621. =head2 $object-E<gt>B<tie_properties> ($all=FALSE)
  622.  
  623. =over
  624.  
  625. =over
  626.  
  627. =item * $all (boolean) if FALSE (or omitted) tie only properties for this object's class, if TRUE tie the properties of this and all parent classes.
  628.  
  629. =back
  630.  
  631.  
  632. A special method avaiable to Glib::Object derivatives, it uses perl's tie
  633. facilities to associate hash keys with the properties of the object. For
  634. example:
  635.  
  636.   $button->tie_properties;
  637.   # equivilent to $button->set (label => 'Hello World');
  638.   $button->{label} = 'Hello World';
  639.   print "the label is: ".$button->{label}."\n";
  640.  
  641. Attempts to write to read-only properties will croak, reading a write-only
  642. property will return '[write-only]'.
  643.  
  644. Care must be taken when using tie_properties with objects of types created with
  645. Glib::Object::Subclass as there may be clashes with existing hash keys that
  646. could cause infinite loops. The solution is to use custom property get/set
  647. functions to alter the storage locations of the properties.
  648.  
  649. =back
  650.  
  651.  
  652. =head1 SIGNALS
  653.  
  654. =over
  655.  
  656. =item B<notify> (Glib::Object, Glib::ParamSpec)
  657.  
  658. =back
  659.  
  660.  
  661. =head1 ENUMS AND FLAGS
  662.  
  663. =head2 flags Glib::SignalFlags
  664.  
  665.  
  666.  
  667. =over
  668.  
  669. =item * 'run-first' / 'G_SIGNAL_RUN_FIRST'
  670.  
  671. =item * 'run-last' / 'G_SIGNAL_RUN_LAST'
  672.  
  673. =item * 'run-cleanup' / 'G_SIGNAL_RUN_CLEANUP'
  674.  
  675. =item * 'no-recurse' / 'G_SIGNAL_NO_RECURSE'
  676.  
  677. =item * 'detailed' / 'G_SIGNAL_DETAILED'
  678.  
  679. =item * 'action' / 'G_SIGNAL_ACTION'
  680.  
  681. =item * 'no-hooks' / 'G_SIGNAL_NO_HOOKS'
  682.  
  683. =back
  684.  
  685.  
  686.  
  687. =head1 SEE ALSO
  688.  
  689. L<Glib>
  690.  
  691. =head1 COPYRIGHT
  692.  
  693. Copyright (C) 2003-2008 by the gtk2-perl team.
  694.  
  695. This software is licensed under the LGPL.  See L<Glib> for a full notice.
  696.  
  697.  
  698. =cut
  699.  
  700.